/*!
 * \file	game.c
 * \brief	The main game loop code for Qong.
 * \author	Jon "delrio" Cox
 * \date	February 2, 2011
 */

//------------------------------------------------------------------------//
//  Qong                                                                  //
//  Copyright (C) 2011 Jon Cox                                            //
//                                                                        //
//  This program is free software: you can redistribute it and/or modify  //
//  it under the terms of the GNU General Public License as published by  //
//  the Free Software Foundation, either version 3 of the License, or     //
//  (at your option) any later version.                                   //
//                                                                        //
//  This program is distributed in the hope that it will be useful,       //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of        //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
//  GNU General Public License for more details.                          //
//                                                                        //
//  You should have received a copy of the GNU General Public License     //
//  along with this program.  If not, see <http://www.gnu.org/licenses/>. //
//------------------------------------------------------------------------//

#include <game.h>
#include <types.h>
#include <stdlib.h>
#include <SDL.h>


// TODO: Main loop.

/*!
 * \brief		Function to run the single-player game mode.
 * \param scoreLimit	Score to start players at. Game ends at Zero.
 * \param flags		Options for the game.
 */
bool_t spGame( int scoreLimit, Uint32 flags )
{
	bool_t running = true;
	SDL_Event event;
	// TODO: Instantiate four players.

	// TODO: Initialize game settings.
	

	// TODO: Countdown, 3-2-1-GO.
	
	// TODO: The game.
	while ( running )
	{
		SDL_WaitEvent( &event );
		switch ( event.type )
		{
			// See if it's a timer or what.
			case SDL_USEREVENT:
				
				break;
			case SDL_KEYDOWN:
				
				break;
			case SDL_KEYUP:
				
				break;
			case SDL_QUIT:
				return false;
		}
	}

	// TODO: Get rid of this when complete.
	return true;
}

/*!
 * \brief		Game loop timer.
 * \param interval	Interval till next trigger.
 * \param param		Data to supply to timer.
 *
 * Credit to meandmark.com for the Timer howto.
 * http://www.meandmark.com/sdlopenglpart5.html
 */
Uint32 gameLoopTimer( Uint32 interval, void *param )
{
	SDL_Event event;

	event.type = SDL_USEREVENT;
	event.user.code = t_RUNLOOP;
	event.user.data1 = 0;
	event.user.data2 = 0;

	SDL_PushEvent( &event );

	return interval;
}
